// JavaScript Document
// JavaScript Document
function createObject() 
{
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
	{
		request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
	request_type = new XMLHttpRequest();
	}
	return request_type;
}

var http = createObject();

var nocache = 0;

function loadRequestAdmin(page) 
{
	showLoadingPage();
	http.open('get', 'process/processRequestAdmin.php?page='+page);
	http.onreadystatechange = loadRequestAdminReply;
	http.send(null);

}
function loadRequestAdminReply()
{
	if(http.readyState == 4){
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	$("#tablerequest").html(response);
	$("#loadingpage").fadeOut(1000);
	if($("#msg").html()=='Successful!')
	{
		alert('xong');
	}
	}
}

function insert() 
{
	// Optional: Show a waiting message in the layer with ID login_response

	showLoadingPage();
	var tenGame= encodeURI(document.getElementById('txtTenGame').value);
	tenGame=tenGame.replace('#','\#');
	tenGame=tenGame.replace('?','\?');
	var linkGame = encodeURI(document.getElementById('txtLinkGame').value);
	var Price= encodeURI(document.getElementById('txtPrice').value);
	var Type = encodeURI(document.getElementById('cbxType').value);
	var device = encodeURI(document.getElementById('cbxDevice').value);
	var hot = encodeURI(document.getElementById('chkHot').checked?1:0);
	// Set te random number to add to URL request
	nocache = Math.random();
	// Pass the login variables like URL variable
	http.open('get', 'process/insert.php?Hot='+hot+'&Device='+device+'&Ten_Game='+tenGame+'&Link_Game=' +linkGame+'&Price='+Price+'&Type='+Type+'&nocache = '+nocache);
	http.onreadystatechange = insertReply;
	http.send(null);

}
function insertReply()
{
	if(http.readyState == 4){
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	
	$("#review").html(response);
	$("#loadingpage").fadeOut(1000);
	}
}